package com.market.service.impl;

import com.market.entity.SendBack;
import com.market.mapper.SendBackMapper;
import com.market.service.SendBackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SendBackServiceImpl implements SendBackService {
    @Autowired
    private SendBackMapper sendBackMapper;

    @Override
    public boolean addSendBackRecord(SendBack sendBack) {
        int i = sendBackMapper.insertSendBack(sendBack);
        if (i==1){
            return true;
        }
        return false;
    }

    @Override
    public List<SendBack> findSendBackRecords(int buyerId) {
        if (buyerId<=0){
            return new ArrayList<>();
        }
        List<SendBack> res = sendBackMapper.selectSendBackByBuyerId(buyerId);
        return res;
    }

    @Override
    public boolean modifySendBackState(int orderId, int state) {
        int i = sendBackMapper.modifySendBackState(orderId, state);
        if (i==1){
            return true;
        }
        return false;
    }

    @Override
    public boolean deleteSendBack(int id) {
        return false;
    }

    @Override
    public SendBack findSendBack(int id) {
        return null;
    }

    @Override
    public List<SendBack> queryAllSendBack() {
        List<SendBack> sendBacks = sendBackMapper.queryAllSendBack();
        return sendBacks;
    }
}
